class RomanRange():

    def __init__(self, unit, unit_symbol, five_symbol):
        self.unit = unit
        self.unit_symbol = '' + unit_symbol

        #The '5' symbol is optional for now because
        #I don't know the one for 5000. 
        if (five_symbol != None):
            self.five_symbol = '' + five_symbol
        else:
            self.five_symbol = None

        self.next = None

    def to_roman(self, decimal_value):
        value_in_units = self.convert_to_one_to_ten_value(decimal_value)

        if (value_in_units <= 0):
            return ''

        result = ''

        if (value_in_units < 4):
            result = self.unit_symbol_times(value_in_units)
        else:
            remaining = value_in_units - 5
            if (remaining < 0):
                result = self.five_symbol_minus_one()
            else:
                if (remaining > 3):
                    result = self.next_symbol_minus_one()
                else:
                    result = self.five_symbol + (self.unit_symbol_times(remaining))

        return result

    def five_symbol_minus_one(self):
        return self.unit_symbol + self.five_symbol

    def next_symbol_minus_one(self):
        return self.unit_symbol + self.next.unit_symbol

    def unit_symbol_times(self, value_in_units):
        return self.unit_symbol * value_in_units

    def convert_to_one_to_ten_value(self, decimal_value):
        return int(decimal_value % (self.unit * 10)) / self.unit

    def enumerate(self):
        curr = self
        while curr != None:
            yield curr
            curr = curr.next
